package com.bawei.bydayzg_two.adapter

import android.widget.CheckBox
import android.widget.ImageView
import android.widget.TextView
import com.bawei.base.bean.CartItem0
import com.bawei.bydayzg_two.R
import com.bawei.bydayzg_two.Utils.GildUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class CartAdapter:BaseQuickAdapter<CartItem0,BaseViewHolder>(R.layout.item_cart) {
    override fun convert(holder: BaseViewHolder, item: CartItem0) {
        //复选乱
        holder.getView<CheckBox>(R.id.cart_cb).isChecked = item.isChecked
        //
        GildUtils.loadImg(holder.itemView.context,item.image,holder.getView(R.id.car_iv))
        holder.setText(R.id.cart_name,item.storeName)
        holder.setText(R.id.cart_sku,"属性：${item.suk}")
        holder.setText(R.id.cart_price,"$${item.price}")
        holder.setText(R.id.cart_num,item.cartNum.toString())
        //当数量为1时数量不可点击
        holder.getView<TextView>(R.id.cart_sub).isEnabled = item.cartNum != 1
    }
}